icon_names_c = \
google \
cp \
rp \
sp
icon_names = $(icon_names_c) hktv

if INSTALL_FAVICON
  pkgpixmaps_16_DATA = $(icon_names:=.png)
endif

google.ico:
	wget "http://www.google.com/favicon.ico" -O $@ || rm $@
#kp.ico:
#	wget "http://kp.podzone.net/favicon.ico" -O $@ || rm $@
#xp.ico:
#	wget "http://extremeyp.ath.cx/favicon.ico" -O $@ || rm $@
cp.ico:
	wget "http://cp.webhop.net/favicon.ico" -O $@ || rm $@
rp.ico:
	wget "http://retro.servegame.org/favicon.ico" -O $@ || rm $@
sp.ico:
	wget "http://bayonet.aa0.netvolante.jp/sp/favicon.ico" -O $@ || rm $@

google.png: google.ico
	convert $< $@ || rm $<
#kp.png: kp.ico
#	convert $< -delete 0 $@ || rm $<
#xp.png: xp.ico
#	convert $< -delete 1 $@ || rm $<
cp.png: cp.ico
	convert $< -delete 0 $@ || rm $<
rp.png: rp.ico
	convert $< $@ || rm $<
sp.png: sp.ico
	convert $< -delete 1 $@ || rm $<

BUILT_SOURCES = icon_decl.h icon_impl.cpp icon_builtin_icon_list.h

icon_decl.h: Makefile
	rm -f $@
	@for n in $(icon_names);do name=$$(echo "$$n" | tr "[a-z]" "[A-Z]");echo "static const char *$$name;" >> $@;done
icon_impl.cpp: Makefile
	rm -f $@
	@for n in $(icon_names);do name=$$(echo "$$n" | tr "[a-z]" "[A-Z]");echo "const char *IconManager::$$name = \"$$n\";" >> $@;done
icon_builtin_icon_list.h: Makefile
	rm -f $@
	@for n in $(icon_names);do name=$$(echo "$$n" | tr "[a-z]" "[A-Z]");echo "$$name," >> $@;done

EXTRA_DIST = hktv.png

CLEANFILES = $(icon_names_c:=.png) $(BUILT_SOURCES)
